﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace proRFID_DiemDanh.Lop
{
    public partial class Lop : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
                doluoi(0);
        }
        void doluoi(int malop)
        {
            rpt_danhsach.DataSource = mdLop.lop_select(malop);
            rpt_danhsach.DataBind();
        }
        protected void cmd_them_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("../Lop/ThemLop.aspx");
        }
        String Xoa()
        {
            if (string.IsNullOrEmpty(Request["xoa"]))
                return "";
            return Request["xoa"].ToString();
        }
        protected void cmd_xoa_Click(object sender, ImageClickEventArgs e)
        {

            string[] test = null;
            string Mangchon = Xoa();
            char[] c = new char[] { ' ', ',' };
            test = Mangchon.ToString().Split(c);
            if (!string.IsNullOrEmpty(Mangchon))
            {
                for (int i = 0; i < test.Length; i++)
                    mdLop.lop_delete(Convert.ToInt32(test[i]));

                doluoi(0);
                return;
            }
        }

    }
}